<?php
include TMPL_PATH.'public/header.phtml';
?>
<script language="javascript" type="text/javascript" src="/admin/Tpl/public/js/jquery-1.4.2.min.js"></script>
<script src="/statics/js/plugins/artDialog/jquery.artDialog.js?skin=default"></script>
<script src="/statics/js/plugins/artDialog/plugins/iframeTools.js"></script>
<link href="/statics/js/showtip/showtips.css" type="text/css" rel="stylesheet">
<script src="/statics/js/showtip/showTip.js" type="text/javascript"></script>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
     	<?php if($step!=1){ ?><a href='javascript:history.go(-1);'><em>上一页</em></a><?php } ?>
    </div>
</div>
<div class="pad_10">
    <div class="table-list">
        <table width="100%" cellspacing="0" >
            <thead>
            <tr>
                <th align='left' width="200">属性</th>
                <th align='left' width="200">属性值</th>
                <th>管理操作</th>
            </tr>
            </thead>
            <tbody>
            <?php
            if(isset($modelList) && $modelList):
                foreach ($modelList as $v):
                    ?>
                    <tr>
                    <?php if($step==2){ ?>
                    	<?php if($v['attr_input_type']==AttributeModel::ATTR_OPTIONAL){?>
                    	<td><?php echo $v['name']?></td>
                        <td><?php echo $v['attr_value']?></td>
                        <td align='center' >
                        	
                            <a href="###" onclick="returnHomepage(<?php echo $v['id'];?>,<?php echo $pid;?>)"><?php echo $name;?></a>
                        </td>
                        <?php } ?>
                    <?php }else{ ?>
                        <td><?php echo $v['name']?></td>
                        <td><?php echo $v['attr_value']?></td>
                        <td align='center' >
                            <a href="<?php echo U('attribute/attribute_list_relation_'.$step, array('id'=>$v['id'],'pid'=>$pid));?>"><?php echo $name;?></a>
                        </td>
                    <?php } ?>    
                    </tr>
                <?php
                endforeach;
            endif;
            ?>
            </tbody>
        </table>
    </div>
<script>
function returnHomepage(val,pid){
	if(val){
		$.ajax({
			type:"POST",
			url: "<?php echo U('attribute/quick_add_attribute');?>",
			data:{attr_id:val,pid:pid},
			dataType:"json",
			success:function(obj){
				showTip(obj.message);
				if(obj.code==200){
					//刷新父窗口
					var win = art.dialog.open.origin;  
					win.location.reload();
					//关闭子窗口 
					setTimeout("art.dialog.close()", 2000 );
				}	
			}
		});
	}
}
</script>    
</div>
</body>
</html>